// 大数据第三题
// author ：lbc
package homework1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;



public class FileToTerminal {
    public static void main(String [] args) throws IOException, URISyntaxException {
        Configuration conf = new Configuration();
        String hdfsPath = "hdfs://localhost:9000";
        FileSystem hdfs = FileSystem.get(new URI(hdfsPath), conf);
        String filePathHdfs = "hdfstest/demo.py";
        Path p = new Path(filePathHdfs);
        FSDataInputStream in = hdfs.open(p);
        BufferedReader buf = new BufferedReader(new InputStreamReader(in));
        String line = null;
        while(true){
            line = buf.readLine();
            if(line == null) break;
            System.out.println(line);
        }
        buf.close();
        in.close();
        hdfs.close();
    }
}
